#!/bin/sh

docker_install_gitea() {
	if [ ! -d /srv/docker/gitea ]; then
		mkdir -p /srv/docker/gitea
		chgrp -R docker /srv/docker
		chmod g+w /srv/docker/gitea
		sudo cp ./gitea/etc/nginx/sites-available/gitea /etc/nginx/sites-available/gitea 
		if [ ! -f /etc/nginx/sites-enabled/gitea ]; then
			sudo ln -s /etc/nginx/sites-available/gitea /etc/nginx/sites-enabled/gitea
		fi
		sudo systemctl reload nginx
		if [ ! -f /srv/docker/gitea/docker-compose.yml ]; then
			sudo cp ./srv/docker/gitea/docker-compose.yml /srv/docker/gitea/docker-compose.yml 
		fi
		docker compose up -d /srv/docker/gitea/docker-compose.yml 
	fi
}

install_gitea() {
    if [ ! -e $(which gitea)]; then
        yay -S gitea
    fi
}

install_gitea
